﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using WLMCoreLibrary;
using SAW_Core;
using Newtonsoft.Json;
using System.Text;


namespace SAW.Ajax
{
    public partial class ListaProductos : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            dbConnector ConexionDB = new dbConnector();
            FuncionesLocales.CheckPagePermision(ref ConexionDB);
            ProductoCollection lista;
                if (Request["idProveedor"] != null)
                    lista = new ProductoCollection( new Proveedor(Convert.ToInt32(Request["idProveedor"]),ref ConexionDB),ref ConexionDB);
                else
                    lista = new ProductoCollection(ref ConexionDB);
           
            FuncionesLocales.NoCache();
            string cadena = JsonConvert.SerializeObject(lista.Elementos, Newtonsoft.Json.Formatting.Indented);
            HttpContext.Current.Response.AddHeader("Expires", " Mon, 26 Jul 1997 05:00:00 GMT");
            HttpContext.Current.Response.AddHeader("Last-Modified", DateTime.UtcNow.ToString());
            HttpContext.Current.Response.AddHeader("Cache-Control", " no-cache, must-revalidate");
            HttpContext.Current.Response.AddHeader("Pragma", "no-cache");
            HttpContext.Current.Response.AddHeader("Content-type", "text");
            Response.Write(cadena);
            ConexionDB.CloseConnection();
        }
    }
}